package leetcode.数组;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author: levi
 * @description: https://leetcode.cn/problems/find-all-numbers-disappeared-in-an-array/
 * @date: 2022-9-14 13:50
 * @version: 1.0
 * 输入：nums = [4,3,2,7,8,2,3,1]
 * 输出：[5,6]
 */
public class 找到所有数组中消失的数字_448 {
    public static void main(String[] args) {

    }

    public static List<Integer> findDisappearedNumbers(int[] nums) {
        if(nums == null) return null;
        List<Integer> result = new ArrayList<>();
        Map<Integer,Integer> map = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            map.put(nums[i],nums[i]);
        }
        for (int i = 0; i < nums.length; i++) {
            if(!map.containsKey(i)){
                result.add(nums[i]);
            }
        }
        return result;
    }
}
